How can I acces links in different folders?

I'm trying to loop through all the links in the module, and display their text, the problem exists if the link is in a different folder - nothing gets displayed? What is my problem?

for LinkReference in CurrentObj<-"*" do
{
string LnkName = fullName(source LinkReference)
if (!open(module LnkName))
{
read(LnkName, false)
}
else
{
print "cant open " LnkName "\n"
}
}

for CurrentLink in CurrentObj<-"*" do
{
Object TestObject = source(CurrentLink)
reportFile << identifier(CurrentObj) " "
reportFile << CurrentObj."Object Text"""
reportFile << " ==========> " TestObject."Object Text""\n\n"
}
NatL - Tue Jul 13 09:59:35 EDT 2010

Re: How can I acces links in different folders?
ostanescu - Tue Jul 13 14:31:21 EDT 2010

Your problem is that you are opening the Link Module instead of the actual module that has the source object.
Try this code from one of my scripts:

ModuleVersion mv
ModName_ srcMod

void openAllRefModules(Object o, string linkModule) {
Module m
LinkRef lr
for lr in all(o<-linkModule) do {
mv = sourceVersion lr
srcMod = module mv
if(!null srcMod) {
if(!isDeleted srcMod and null data mv) {
m = load(mv, false)
//you may want to add m to a Skip list so you can close it later

}
}
}
}
Object o = current
Object src = null
Link l

//open all modules that are in-linked
openAllRefModules(o, "*")

for l in all(o<-"*") do {
mv = sourceVersion l
srcMod = module mv
if(null srcMod or isDeleted srcMod) continue
src = source l
if(null src or isDeleted src) continue
//do whatever with src object
print identifier src "\n"

}

Octavian

Re: How can I acces links in different folders?
llandale - Tue Jul 13 15:13:09 EDT 2010

You seem to have a minor bug, where if the source module is indeed already open then you print "cant open". Since you are printing nothing then the first loop isn't doing anything.

I suspect the reason the first loop isn't doing anything is because you have not declared variable "LinkReference", which perhaps is getting 'auto declared' as a type "Link" instead of "LinkRef". Add this: "LinkRef LinkReference" at the top.

Tsk tsk tsk, auto-declare bytes royally.

  • Louie

Re: How can I acces links in different folders?
NatL - Tue Jul 13 15:46:17 EDT 2010

ostanescu - Tue Jul 13 14:31:21 EDT 2010
Your problem is that you are opening the Link Module instead of the actual module that has the source object.
Try this code from one of my scripts:

ModuleVersion mv
ModName_ srcMod

void openAllRefModules(Object o, string linkModule) {
Module m
LinkRef lr
for lr in all(o<-linkModule) do {
mv = sourceVersion lr
srcMod = module mv
if(!null srcMod) {
if(!isDeleted srcMod and null data mv) {
m = load(mv, false)
//you may want to add m to a Skip list so you can close it later

}
}
}
}
Object o = current
Object src = null
Link l

//open all modules that are in-linked
openAllRefModules(o, "*")

for l in all(o<-"*") do {
mv = sourceVersion l
srcMod = module mv
if(null srcMod or isDeleted srcMod) continue
src = source l
if(null src or isDeleted src) continue
//do whatever with src object
print identifier src "\n"

}

Octavian

Thank you, much appreciated